package com.hrms.controller;


import com.hrms.domain.User;
import com.hrms.domain.web.AjaxResult;
import com.hrms.domain.web.LoginInfo;
import com.hrms.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: zhuyupeng
 * @date: 2024/12/19 - 11:24
 * @mail: 1321561134@qq.com
 * @info:
 */
@Slf4j
@RestController
@RequestMapping("/admin/user")
public class UserController extends BaseController
{
    @Autowired
    private IUserService userService;

    /**
     * 用户登录
     * @param user
     * @return
     */
    @PostMapping("/login")
    public AjaxResult login(@RequestBody User user){
        log.info("员工来登录啦 , {}", user);
        LoginInfo loginInfo = userService.login(user);
        if(loginInfo != null){
            return AjaxResult.success(loginInfo);
        }
        return AjaxResult.error("用户名或密码错误~");
    }
}
